<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>部门积分操作</title>
	<link rel="stylesheet" href="__CSS__/pintuer.css?v={$src_version}">
	<link rel="stylesheet" href="__CSS__/admin.css?v={$src_version}">
	<link rel="stylesheet" href="__CSS__/responsive.css?v={$src_version}">
	<script src="__JS__/jquery-3.2.1.min.js?v={$src_version}"></script>
	<script src="__JS__/pintuer.js?v={$src_version}"></script>
	<script src="__JS__/jquery.nicescroll.js"></script>
	<script src="__PUBLIC__/layer.js?v={$src_version}"></script>
	<script src="__JS__/ming.js?v={$src_version}"></script>
	<script src="__JS__/ifram_scroll.js?v={$src_version}"></script>
	<script src="__JS__/responsive.js?v={$src_version}"></script>
</head>
<body>
	<form action=""  class="form-x"  method="get" >
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>部门积分操作</strong>
		</div>
		<input type="text" name="id" id="uid" value="{$user.uid}" style="display: none;" />
		<div class="body-content">
			<div class="form-group">
				<div class="label">
				<label>请选择部门：</label>
				</div>
				<div class="field">
					<select class="input w50" name="branch" id="branch">
						<option value=""></option>
						<volist name="type" id="vo" key="i">
						<option value="{$vo.id}">{$vo.brank_name}</option>
						</volist>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="label">
				<label>请选择加减分：</label>
				</div>
				<div class="field">
					<select  class="input w50" name="opt" id="ad" onchange="ajax()">
						<option value=""></option>
						<option value="add">加分项目</option>
						<option value="less">减分项目</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="label">
				<label>请选择项目：</label>
				</div>
				<div class="field">
					<select class="input w50"  name="type" id="type">
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="label">
				<label>加/减分数量：</label>
				</div>
				<div class="field" id="number-div">
					<input type="text" class="input w50"  name="add_number" id="number1" value="">
				</div>
			</div>
			<div class="form-group">
				<div class="label">
				<label>请填写备注：</label>
				</div>
				<div class="field">
					<input type="text" class="input w50" name="note" id="nt">
				</div>
			</div>
			<div class="form-group">
				<div class="label">
					<label></label>
				</div>
				<div class="field">
					<div class="button-group">
					<a class="button bg-main"  onclick="tijiao()" >
						<span class="icon-check-square-o"></span> 提交
					</a>
					<a class="button border-main" href="javascript:history.go(-1)">
						<span class="icon-mail-reply"></span> 返回</a>
					</div>
				</div>
			</div>
		  
		</div>



		
		<!-- <li><span>请选择部门：</span></li>
		<li><select name="branch" id="branch">
			<option value=""></option>
			<volist name="type" id="vo" key="i">
			<option value="{$vo.id}">{$vo.brank_name}</option>
			</volist>
		</select></li>
		<li><span>请选择加减分：</span></li>
		<li><select name="opt" id="ad" onchange="ajax()">
			<option value=""></option>
			<option value="add">加分项目</option>
			<option value="less">减分项目</option>
		</select></li>
		<li><span>请选择项目：</span></li>
			<li><select name="type" id="type" onchange="add_num()">
							</select></li>
			<li><span>加/减分数量</span></li>
		<li><input type="text" name="add_number" id="number" value="" readonly="readonly"></li>
		
		
		
		
		<li><span>请填写备注：</span></li>
		<li><input type="text" name="note" id="nt"></li>
		<li><input type="button" onclick="tijiao()" value="提交"></li> -->
	</form>
</body>
<script>
	function ajax()
	{		
		var  branch=document.getElementById("branch");
		var  ad=document.getElementById("ad");
		 var xmlhttp;
  		 var bid = branch.value;
  		 var opt = ad.value;
		  
  		if (window.XMLHttpRequest)
  		{
    // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
    		xmlhttp=new XMLHttpRequest();
 		 }
  		else
  		{
    // IE6, IE5 浏览器执行代码
   			 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
  		 xmlhttp.open("GET","{:U('User/number')}?bid="+bid+"&opt="+opt,true);
  		 xmlhttp.send();
  		xmlhttp.onreadystatechange=function()
  		{
   			 if (xmlhttp.readyState==4 && xmlhttp.status==200)
    			{
     				 var obj = xmlhttp.responseText;

     				 if (obj != '') 
     				 {
     				 	jiexi(obj);
     				 }
    			}
  		}
 
	}
	$("#number1").click(function(){
		//获取部门
		var branch = $('#branch').val();
		//获取项目
		var types = $('#type').val();
		if(branch==''|| types==''){
			layer.alert('项目或部门不能为空！', {closeBtn: 0});
		}else{
			jiden_qujian_ajax(branch,types);
		}
	})
	//获取积分区间ajax
	function jiden_qujian_ajax(branch,types){
		$.post("{:U('User/jiden_qujian_ajax')}",{type:types,branch:branch},function(data){
			console.log(data);
			if(data.code==200){
				var str = '<input type="number" min="'+data.data.min+'" max="'+data.data.max+'" class="input w50"  name="add_number" id="number1" value=""><span style="line-height:44px;padding-left:10px">最大值为'+data.data.max+',最小值为'+data.data.min+'</span>'
				$('#number-div').html(str);
			}
		},'json');
<<<<<<< HEAD


=======
>>>>>>> 0759c44835df3f14761ebfe0d6efb0d5026310d0
	}

	function jiexi(obj)
	{
		var change = eval('('+obj+')');
		var len = change.length;
		var full = document.getElementById('type');
		full.innerHTML = '';
		full.innerHTML = '<option value="">'+"</option>";
		for(var i=0 ; i<len ; i++)
		{
		
		full.innerHTML += '<option value="'+change[i]['category_name']+'">'+
			change[i]['category_name']+
			"</option>";
		}
	}

	// function add_num()
	// {
	// 	var value = type.value;
	// 	document.getElementById('number1').value = value;
	// }
	
	function tijiao()
	{
		
		var note = nt.value;
		var id = uid.value;
		var opt = ad.value;
		var add_number = number1.value;
		var bid = branch.value;
		var type=$("#type  option:selected").text();
		// console.log(note,id,opt,add_number,bid,type)
		//alert(add_number);
		if (window.XMLHttpRequest)
  		{
    // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
    		xmlhttp=new XMLHttpRequest();
 		 }
  		else
  		{
    // IE6, IE5 浏览器执行代码
   			 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
  		 xmlhttp.open("GET","{:U('User/add_pint')}?id="+id+"&opt="+opt+"&note="+note+"&add="+add_number+"&bid="+bid+"&type="+type,true);
  		 xmlhttp.send();
  		xmlhttp.onreadystatechange=function(res)
  		{
   			 if (xmlhttp.readyState==4 && xmlhttp.status==200)
    			{
     				 if(xmlhttp.responseText!=""){
						  location.href="{:U('User/index')}";
					  }
    			}
  		}
	}
</script>
</html>